import requests
from flask import Blueprint, jsonify, request

isbns = Blueprint('isbns', __name__)


@isbns.route('/isbns')
def get_book_by_isbn():
    isbn = request.args.get('isbn')
    if isbn is None:
        return {
            'error': 'ISBN is required'
        }, 400
    params = {
        'key': '7f7cefbf67f5bd645ccade9ae85aef41',
        'isbn': isbn
    }
    response = requests.get('http://api.tanshuapi.com/api/isbn/v1/index', params=params)
    return jsonify(response.json()), response.status_code
